package com.springBoot.controller;

import com.springBoot.domain.Enterprise;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/books")
public class BookController {
    @Value("${lesson}")
    private String lesson;

    @Value("${server.port}")
    private Integer port;
    @Value("${enterprise.subject[0]}")
    private String subject;

    @Autowired
    private Environment environment;
    @Autowired
    private Enterprise enterprise;
    @GetMapping("/{id}")
    public String getById(@PathVariable Integer id) {
        System.out.println(id);
        System.out.println(environment.getProperty("lesson"));
        return "get ok!!!" + enterprise.getName()+"--"+enterprise.getAge()+"---"+enterprise.getSubject();
    }
}
